package com.example.demo.signature;

import com.example.demo.util.DateUtil;
import com.example.demo.util.Md5SignUtil;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class TestMd5 {

    public static void main(String[] args) {
//        System.out.println(System.currentTimeMillis());
//        long startTime = System.currentTimeMillis();
//        System.out.println(startTime);

        long permanent = 222l;
        permanent = System.currentTimeMillis();

        permanent = get1Minute();
        long Timestamp = 1736738627195l;
//      // d7e334d8087f8def63cb217ff6c8f28d
////      String Authorization  = "qukan-" + time + "-" + Signature;
//      String Signature = MD5.sign("qukan" + "-" + Timestamp + "-","TlGObkEzJOsawwCtoT9aMbeR","utf-8");
//        System.out.println(Signature);
//
//        String s = Md5SignUtil.encryptWithMD5("qukan" + "-" + Timestamp + "-" + "TlGObkEzJOsawwCtoT9aMbeR", "utf-8");
//        System.out.println(s);

        // http://video.people.cn/1.jpg?vkey=62f3b8adee7a112358f4fbc46c5c269e&vtime=1736776581999&keeptime=180

        String key = "upload/vod/user1735982106105323/1736762024358379/origin.mp4";
        key =  "upload/vod/user1735982106105323/1736825108007202/video.mp4";
        key = "userUpload/1735982106105323/1737340316077235/picture/prescreen.png";
        key = "userUpload/1735982106105323/1735982106105323/picture/9834505e-51a1-42ca-8a64-ab6fa846e4b1.jpg";
        // $uri$ourkey$time  wangsu/4/123.mp31601026312
        String sk = MD5.sign("/"+key,"HmDP3nGYtDE9OBkobhDeda3da8fWLi27"+permanent,"utf-8");
        System.out.println("sk:"+sk);
        //http://video.people.cn/userLoad/1.jpg?vkey=d274ce078c5c3baa62405ee4af3d9022&vtime=180
        System.out.println("https://video.people.cn/"+key+"?vkey="+sk+"&vtime="+permanent);

//        System.out.println("http://video.people.cn/1.jpg?vkey="+sk+"&vtime="+180);

        //  userUpload/1735982106105323/1736762024358379/picture/prescreen.png

    }

    private static long get1Minute() {
        // 获取当前时间
        Date currentDate = new Date();
        // 创建 Calendar 实例，并将其设置为当前时间
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(currentDate);
        // 在当前时间的基础上增加一分钟
        calendar.add(Calendar.MINUTE, 1);
        // 获取一分钟后的 Date 对象
        Date oneMinuteLater = calendar.getTime();
        // 将 Date 对象转换为时间戳
        long timestamp = oneMinuteLater.getTime();
        return timestamp;
    }


}
